/*****************************************************************************
*
* File: hw_init.c
*
* Description: Contains functions to initialized hardware on MCU.
*
* Author: Kevin Casteel, Luis Castillo
*
* Revisions: v-1.0 (4/18/11)
*
******************************************************************************/


#include <avr/io.h>
#include <avr/interrupt.h>
#include "hw_init.h"


/*---------------------------------------------------------
* Function: vIO_init
*
* Description: Function initializes port data direction
* 			   and clears it.
*---------------------------------------------------------*/
void vIO_init(void) 
{
    //- set PortB as output
	DDRB = (_BV(PIN2) | _BV(PIN6) | _BV(PIN7)); 
    PORTB = 0x00;
}


/*---------------------------------------------------------
* Function: vINT0_init
*
* Description: Function initializes INT0
*---------------------------------------------------------*/
void vINT0_init(void) 
{
    //- set 
	MCUCR = _BV(ISC00);
	GICR = _BV(INT0);
}


/*---------------------------------------------------------
* Function: vTIMER2_init
*
* Description: Function initializes timer2
*---------------------------------------------------------*/
void vTIMER2_init()
{
    TCCR2 = (_BV(CS22) | _BV(CS21) | _BV(CS20));
	TIMSK = _BV(TOIE2);
}
